﻿using CommonEntity.PackageEntity;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace PackageAPI.Context
{
    public class PackageContext : DbContext
    {
        public PackageContext(DbContextOptions<PackageContext> options)
           : base(options)
        {

        }

        public DbSet<PackageInfo> PackageInfos { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            //初始化数据
            modelBuilder.Entity<PackageInfo>().HasData(new PackageInfo
            {
                ID = 1,
                PhoneName = "华为手机",
                CPUID = 1,
                BatteryID = 1,
                ShellID = 1,
                CreateTime = DateTime.Now
            });
        }
    }
}
